import {appConfigType, pagesConfig} from "@/types/component/core";

const getAppList = async () => {
    const _appList = import.meta.glob('./*/index.tsx')
    const appList: appConfigType | [] = []
    for (const el of Object.keys(_appList)) {
        const res = await _appList[el]()
        // @ts-ignore
        appList.push(res.default)
    }
    return appList
}

const install = async (app) => {
    const appList = await getAppList()
    console.log(appList)
    appList.forEach((appConfig: appConfigType) => {
        appConfig.pages.forEach((page: pagesConfig) => {

            app.component(page.path, page.component)
        })
    })
}

export default {
    getAppList,
    install,
}